// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   PetEquipmentBtn.java

package com.tool.btn;

import com.tool.image.ImageMixDeal;
import com.tool.role.RoleData;
import com.tool.tcpimg.UIUtils;
import java.awt.event.MouseEvent;
import java.math.BigDecimal;

import org.come.Frame.ZhuFrame;
import org.come.Jpanel.PetEquipmentJpanel;
import org.come.entity.Goodstable;
import org.come.entity.RoleSummoning;
import org.come.socket.Agreement;
import org.come.socket.SendMessageUntil;
import org.come.summonequip.JframeSummonEquipMain;
import org.come.summonequip.JpanelSummonEquipMain;
import org.come.until.FormsManagement;
import org.come.until.GoodsListFromServerUntil;
import org.come.until.UserMessUntil;
import org.come.until.Util;

// Referenced classes of package com.tool.btn:
//			MoBanBtn

public class PetEquipmentBtn extends MoBanBtn
{

	private int caozuo;

	public PetEquipmentBtn(String iconpath, int type, String text, int caozuo)
	{
		super(iconpath, type, UIUtils.COLOR_BTNPUTONG2);
		this.caozuo = caozuo;
		setText(text);
		setFont(UIUtils.TEXT_HY16);
		setVerticalTextPosition(0);
		setHorizontalTextPosition(0);
	}


	@Override
	public void chooseyes()
	{
	}

	@Override
	public void chooseno()
	{
	}

	@Override
	public void nochoose(MouseEvent e)
	{
		if (caozuo == 1)
		{
			if (Util.isCanBuyOrno()) {
				return;
			}
			FormsManagement.HideForm(67);
			JframeSummonEquipMain.getJframeSummonEquipMain().getJpanelSummonEquipMain().changeMenuView(-1);
			FormsManagement.showForm(91);
		}else if (caozuo==2){
			if (ImageMixDeal.userimg.getRoleShow().getBooth_id() != null) {
				ZhuFrame.getZhuJpanel().addPrompt2("摆摊状态不可以操作！");
				return;
			}
			Goodstable[] goodslist = GoodsListFromServerUntil.getGoodslist();
			RoleSummoning pet = UserMessUntil.getChosePetMes();
			if(pet.getFragment()==1200) {
				String msg = "#R召唤兽#G【"+pet.getSummoningname()+"】#R已达到最高星级！";
				ZhuFrame.getZhuJpanel().addPrompt2(msg);
				return ;
			}
			int pettype = Integer.parseInt(pet.getSsn());
			Goodstable good = new Goodstable();
			boolean b = false;
			for(Goodstable goods : goodslist) {
				if(goods!=null && null!=goods.getValue() && !goods.getValue().equals("")) {
					String[] vs = goods.getValue().split("=");
					if(vs.length > 0 && vs[0].equals("神兽")) {
						if(vs[1].equals(pettype+"")) {
							good = goods;
							b = true;
						}
					}
				}
			}
			if(!b) {
				String msg = "召唤兽升星碎片不足！";
				ZhuFrame.getZhuJpanel().addPrompt2(msg);
				return ;
			}
//			if(RoleData.getRoleData().getLoginResult().getGold().compareTo(new BigDecimal(500000)) <0){
//				ZhuFrame.getZhuJpanel().addPrompt2("您的银两不足50W!");
//				return;
//			}
			String value = good.getValue();
			String[] value1=value.split("=");
			boolean flag = false;
//			if(value1[1].equals(pettype+"")) {
			if(pet.getFragment()==0) {
				flag = GoodsListFromServerUntil.isgood(good.getGoodsid().intValue(),30);
			}else if(pet.getFragment()==30) {
				flag = GoodsListFromServerUntil.isgood(good.getGoodsid().intValue(),60);
			}else if(pet.getFragment()==90) {
				flag = GoodsListFromServerUntil.isgood(good.getGoodsid().intValue(),90);
			}else if(pet.getFragment()==180) {
				flag = GoodsListFromServerUntil.isgood(good.getGoodsid().intValue(),120);
			}else if(pet.getFragment()==300) {
				flag = GoodsListFromServerUntil.isgood(good.getGoodsid().intValue(),150);
			}else if(pet.getFragment()==450) {
				flag = GoodsListFromServerUntil.isgood(good.getGoodsid().intValue(),180);
			}else if(pet.getFragment()==600) {
				flag = GoodsListFromServerUntil.isgood(good.getGoodsid().intValue(),210);
			}else if(pet.getFragment()==750) {
				flag = GoodsListFromServerUntil.isgood(good.getGoodsid().intValue(),240);
			}else if(pet.getFragment()==900) {
				flag = GoodsListFromServerUntil.isgood(good.getGoodsid().intValue(),270);
			}else if(pet.getFragment()==1050) {
				flag = GoodsListFromServerUntil.isgood(good.getGoodsid().intValue(),300);
			}else if(pet.getFragment()==1200) {
				String msg = "#R召唤兽#G【"+pet.getSummoningname()+"】#R已达到最高星级！";
				ZhuFrame.getZhuJpanel().addPrompt2(msg);
				return ;
			}
//			}
//		else {
//				String msg = "只有神兽才可以升星！";
//				ZhuFrame.getZhuJpanel().addPrompt2(msg);
//				return ;
//			}
			if(!flag) {
				String msg = "#R召唤兽【#G"+pet.getSummoningname()+"#R】升星碎片数量不足！";
				ZhuFrame.getZhuJpanel().addPrompt2(msg);
				return ;
			}
			if(RoleData.getRoleData().getLoginResult().getGold().compareTo(new BigDecimal(5000000)) <0){
				ZhuFrame.getZhuJpanel().addPrompt2("您的银两不足500W!");
				return ;
			}
			SendMessageUntil.toServer(Agreement.getAgreement().petUpStar("SX="+pet.getSid()+"="+good.getRgid()));
			PetEquipmentJpanel.starRating = pet.getFragment();
		}
	}
}
